package com.lzz.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * @Author 小思
 * @Description //TODO
 * @Date $ $
 * @Param $
 * @return $
 **/

public class MybatisConfig {
    //
    @Bean
    public SqlSessionFactoryBean sqlSessionFactoryBean(DataSource dataSource) {
        SqlSessionFactoryBean sql = new SqlSessionFactoryBean();
        //实体类包 数据源
        sql.setTypeAliasesPackage("com.lzz.domain");
        sql.setDataSource(dataSource);
        return sql;
    }

    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer ma = new MapperScannerConfigurer();
        //数据层包
        ma.setBasePackage("com.lzz.dao");
        return ma;
    }
}
